<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>沙箱支付</title>
</head>

<body>
    <button>点击开启支付</button>
    <script>
        document.querySelector('button').addEventListener('click', () => {
            const data = {
                "id": "fffehrwiyrewy434342287565598"
            }
            const xhr = new XMLHttpRequest()
            xhr.open('POST', 'http://localhost:3031/realizePay')
            xhr.send(data)
            xhr.addEventListener('readystatechange', () => {
                if (xhr.readyState == 4) {
                    console.log(xhr.response);
                    const data = JSON.parse(xhr.response)
                    console.log(data);
                    location.href = data.result
                }
            })
        })
    </script>
</body>

</html>